import 'package:flutter/material.dart';
import 'package:mobile_app.core/core/presentation/theme/theme.dart';
import 'package:mobile_app.core/core/presentation/utils/icons/custom_regular_icons.dart';
import 'package:mobile_app.core/core/presentation/widgets/app_icon_button.dart';
import 'package:mobile_app.core/core/presentation/widgets/platform_divider.dart';
import 'package:mobile_app.core/core/presentation/widgets/shake_built_transition.dart';
import 'package:mobile_app.core/core/presentation/widgets/tiles/tile_rounder.dart';
import 'package:mobile_app.core/core/presentation/widgets/tiles/tile_text_field.dart';
import 'package:mobile_app.home.core/core/presentation/localization/translation.dart';

class UseCaseEditingTileGroup extends StatelessWidget {
  const UseCaseEditingTileGroup({
    required this.exampleShakeAnimationController,
    required this.translationShakeAnimationController,
    required this.exampleEditingController,
    required this.translationEditingController,
    required this.exampleFocusNode,
    required this.translationFocusNode,
    required this.onExampleSubmitted,
    required this.onTranslationSubmitted,
    required this.onUseCaseRemove,
    super.key,
  });

  final AnimationController exampleShakeAnimationController;
  final AnimationController translationShakeAnimationController;
  final TextEditingController exampleEditingController;
  final TextEditingController translationEditingController;
  final FocusNode exampleFocusNode;
  final FocusNode translationFocusNode;
  final VoidCallback onExampleSubmitted;
  final VoidCallback onTranslationSubmitted;
  final VoidCallback onUseCaseRemove;

  @override
  Widget build(BuildContext context) {
    const kIconButtonSize = 50.0;

    return TileTopRounder(
      tile: TileBottomRounder(
        tile: Container(
          color: CoreTheme.of(context).tileColor,
          child: Row(
            children: [
              Expanded(
                child: Column(
                  children: [
                    ShakeBuiltTransition(
                      controller: exampleShakeAnimationController,
                      child: TileTextField(
                        autocorrect: true,
                        enableSuggestions: true,
                        maxLines: null,
                        controller: exampleEditingController,
                        focusNode: exampleFocusNode,
                        keyboardType: TextInputType.text,
                        placeholder: HomeCoreTranslation.of(context).useCaseExamplePlaceholder,
                        textInputAction: TextInputAction.next,
                        onSubmitted: onExampleSubmitted,
                      ),
                    ),
                    const PlatformDivider(),
                    ShakeBuiltTransition(
                      controller: translationShakeAnimationController,
                      child: TileTextField(
                        autocorrect: true,
                        enableSuggestions: true,
                        maxLines: null,
                        controller: translationEditingController,
                        focusNode: translationFocusNode,
                        keyboardType: TextInputType.text,
                        placeholder: HomeCoreTranslation.of(context).useCaseTranslationPlaceholder,
                        textInputAction: TextInputAction.next,
                        onSubmitted: onTranslationSubmitted,
                      ),
                    ),
                  ],
                ),
              ),
              AppIconButton(
                height: kIconButtonSize,
                width: kIconButtonSize,
                icon: Icon(
                  CustomRegularIcons.minus_circled,
                  size: 27,
                  color: CoreTheme.of(context).primaryColor,
                ),
                onPressed: onUseCaseRemove,
              ),
            ],
          ),
        ),
      ),
    );
  }
}
